/***
 * A collection of Discard pile
 * 
 */

package it.stessaro.lostcities.collection;

import it.stessaro.lostcities.collection.pile.ColorPile;
import it.stessaro.lostcities.core.Costants;
import java.util.ArrayList;
import java.util.List;

public class DiscardPiles extends ArrayList<ColorPile>{
	
	private static final long serialVersionUID = 1L;

	private List<Card> topCards;
	public DiscardPiles() {
		this.add(Costants.RED, new ColorPile(Costants.RED));
		this.add(Costants.WHITE, new ColorPile(Costants.WHITE));
		this.add(Costants.GREEN, new ColorPile(Costants.GREEN));
		this.add(Costants.BLUE, new ColorPile(Costants.BLUE));
		this.add(Costants.YELLOW, new ColorPile(Costants.YELLOW));
	}
	
	public boolean addCard(Card card){
		int pos = card.getCardColor();
			this.get(pos).addCard(card);
			return true;
	}
	

	
	public List<Card> getTopCards(){
		for (ColorPile discard : this) {
			topCards.add(discard.lastCard());
		}
		return topCards;
	}
	public Card drawCard(String colore){
		if (colore.equals("r")) {
			return this.get(0).pop();
		}else if (colore.equals("w")) {
			return this.get(1).pop();
		}else if (colore.equals("g")) {
			return this.get(2).pop();
		}else if (colore.equals("b")) {
			return this.get(3).pop();
		}else{
			return this.get(4).pop();
		}	
	}
	
}
